<template>
  <el-menu
    unique-opened
    default-active="1-4-1"
    class="el-menu-vertical-demo"
    @open="handleOpen"
    @close="handleClose"
    :collapse="isCollapse"
    background-color="#545c64"
    text-color="#fff"
    active-text-color="#ffd04b"
  >
    <h3>{{ isCollapse ? "监测系统" : "防返贫监测系统" }}</h3>
    <el-menu-item
      @click="clickMenu(item)"
      v-for="item in noChildren"
      :key="item.name"
      :index="item.name"
    >
      <i :class="`el-icon-${item.icon}`"></i>
      <span slot="title">{{ item.label }}</span>
    </el-menu-item>
    <el-submenu
      v-for="item in hasChildren"
      :key="item.label"
      :index="item.label"
    >
      <template slot="title">
        <i :class="`el-icon-${item.icon}`"></i>
        <span slot="title">{{ item.label }}</span>
      </template>
      <el-menu-item-group v-for="subItem in item.children" :key="subItem.path">
        <el-menu-item @click="clickMenu(subItem)" :index="subItem.path">{{
          subItem.label
        }}</el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<style lang="less" scoped>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 250px;
  min-height: 400px;
}
.el-menu {
  height: 100vh;
  h3 {
    color: #fff;
    text-align: center;
    line-height: 48px;
    font-size: 16px;
    font-weight: 400;
  }
}
.ml-83 {
  margin-left: 83px;
}
.ml-25 {
  margin-left: 25px;
}
.ml-53 {
  margin-left: 53px;
}
.ml-23 {
  margin-left: 23px;
}
.section {
  padding-bottom: 739px;
  background-color: #ffffff;
  box-shadow: 4px 0px 4px #2b2d3703;
  height: 1237px;
  .text-wrapper {
    padding: 14px 0 39px;
    background-color: #ffffff;
    box-shadow: 0px 1px 0px #2b2d370d;
    width: 255px;
    .text {
      margin-left: 29.5px;
      color: #000000;
      font-size: 22px;
      font-family: SourceHanSansCN;
      line-height: 17px;
    }
  }
  .section_4 {
    margin-top: 33px;
    padding: 17px 13px 17.5px 20px;
    background-color: #0054fe;
    border-radius: 8px;
    .image_3 {
      width: 16.5px;
      height: 15px;
    }
    .text_2 {
      color: #ffffff;
      line-height: 13px;
    }
    .image_4 {
      width: 9px;
      height: 6px;
    }
  }
  .group_7 {
    margin-top: 25px;
    padding-left: 52px;
    padding-right: 45px;
    .group_8 {
      padding: 0 14px;
      .group_9 {
        border-radius: 50%;
        width: 6px;
        height: 6px;
        border-left: solid 1.5px #666666;
        border-right: solid 1.5px #666666;
        border-top: solid 1.5px #666666;
        border-bottom: solid 1.5px #666666;
      }
      .font_4 {
        font-size: 12px;
        font-family: PingFang;
        line-height: 11px;
        color: #74798c;
      }
      .text_11 {
        line-height: 11px;
      }
      .text_14 {
        line-height: 11px;
      }
      .section_7 {
        background-color: #0054fe;
        border-radius: 50%;
        width: 6px;
        height: 6px;
      }
      .font_7 {
        font-size: 12px;
        font-family: 苹方;
      }
      .text_15 {
        color: #0054fe;
        line-height: 11px;
      }
    }
    .image_6 {
      width: 16px;
      height: 16px;
    }
    .image_7 {
      width: 6px;
      height: 10px;
    }
    .image_9 {
      width: 16px;
      height: 19px;
    }
    .text_23 {
      line-height: 13px;
    }
    .image_10 {
      width: 16px;
      height: 16px;
    }
    .text_30 {
      line-height: 13px;
    }
    .image_11 {
      width: 16px;
      height: 17px;
    }
    .text_34 {
      line-height: 13px;
    }
  }
  .font {
    font-size: 14px;
    font-family: 苹方;
    line-height: 13px;
    color: #74798c;
  }
}
/************************************************************
** 请将全局样式拷贝到项目的全局 CSS 文件或者当前页面的顶部 **
** 否则页面将无法正常显示                                  **
************************************************************/

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
  'Droid Sans', 'Helvetica Neue', 'Microsoft Yahei', sans-serif;
}

body * {
  box-sizing: border-box;
  flex-shrink: 0;
}

#app {
  width: 100vw;
  height: 100vh;
}

.flex-row {
  display: flex;
  flex-direction: row;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.justify-start {
  justify-content: flex-start;
}

.justify-end {
  justify-content: flex-end;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-around {
  justify-content: space-around;
}

.justify-evenly {
  justify-content: space-evenly;
}

.items-start {
  align-items: flex-start;
}

.items-end {
  align-items: flex-end;
}

.items-center {
  align-items: center;
}

.items-baseline {
  align-items: baseline;
}

.items-stretch {
  align-items: stretch;
}

.self-start {
  align-self: flex-start;
}

.self-end {
  align-self: flex-end;
}

.self-center {
  align-self: center;
}

.self-baseline {
  align-self: baseline;
}

.self-stretch {
  align-self: stretch;
}

.flex-1 {
  flex: 1 1 0%;
}

.flex-auto {
  flex: 1 1 auto;
}

.grow {
  flex-grow: 1;
}

.grow-0 {
  flex-grow: 0;
}

.shrink {
  flex-shrink: 1;
}

.shrink-0 {
  flex-shrink: 0;
}

.relative {
  position: relative;
}

.ml-2 {
  margin-left: 2px;
}

.mt-2 {
  margin-top: 2px;
}

.ml-4 {
  margin-left: 4px;
}

.mt-4 {
  margin-top: 4px;
}

.ml-6 {
  margin-left: 6px;
}

.mt-6 {
  margin-top: 6px;
}

.ml-8 {
  margin-left: 8px;
}

.mt-8 {
  margin-top: 8px;
}

.ml-10 {
  margin-left: 10px;
}

.mt-10 {
  margin-top: 10px;
}

.ml-12 {
  margin-left: 12px;
}

.mt-12 {
  margin-top: 12px;
}

.ml-14 {
  margin-left: 14px;
}

.mt-14 {
  margin-top: 14px;
}

.ml-16 {
  margin-left: 16px;
}

.mt-16 {
  margin-top: 16px;
}

.ml-18 {
  margin-left: 18px;
}

.mt-18 {
  margin-top: 18px;
}

.ml-20 {
  margin-left: 20px;
}

.mt-20 {
  margin-top: 20px;
}

.ml-22 {
  margin-left: 22px;
}

.mt-22 {
  margin-top: 22px;
}

.ml-24 {
  margin-left: 24px;
}

.mt-24 {
  margin-top: 24px;
}

.ml-26 {
  margin-left: 26px;
}

.mt-26 {
  margin-top: 26px;
}

.ml-28 {
  margin-left: 28px;
}

.mt-28 {
  margin-top: 28px;
}

.ml-30 {
  margin-left: 30px;
}

.mt-30 {
  margin-top: 30px;
}

.ml-32 {
  margin-left: 32px;
}

.mt-32 {
  margin-top: 32px;
}

.ml-34 {
  margin-left: 34px;
}

.mt-34 {
  margin-top: 34px;
}

.ml-36 {
  margin-left: 36px;
}

.mt-36 {
  margin-top: 36px;
}

.ml-38 {
  margin-left: 38px;
}

.mt-38 {
  margin-top: 38px;
}

.ml-40 {
  margin-left: 40px;
}

.mt-40 {
  margin-top: 40px;
}

.ml-42 {
  margin-left: 42px;
}

.mt-42 {
  margin-top: 42px;
}

.ml-44 {
  margin-left: 44px;
}

.mt-44 {
  margin-top: 44px;
}

.ml-46 {
  margin-left: 46px;
}

.mt-46 {
  margin-top: 46px;
}

.ml-48 {
  margin-left: 48px;
}

.mt-48 {
  margin-top: 48px;
}

.ml-50 {
  margin-left: 50px;
}

.mt-50 {
  margin-top: 50px;
}

.ml-52 {
  margin-left: 52px;
}

.mt-52 {
  margin-top: 52px;
}

.ml-54 {
  margin-left: 54px;
}

.mt-54 {
  margin-top: 54px;
}

.ml-56 {
  margin-left: 56px;
}

.mt-56 {
  margin-top: 56px;
}

.ml-58 {
  margin-left: 58px;
}

.mt-58 {
  margin-top: 58px;
}

.ml-60 {
  margin-left: 60px;
}

.mt-60 {
  margin-top: 60px;
}

.ml-62 {
  margin-left: 62px;
}

.mt-62 {
  margin-top: 62px;
}

.ml-64 {
  margin-left: 64px;
}

.mt-64 {
  margin-top: 64px;
}

.ml-66 {
  margin-left: 66px;
}

.mt-66 {
  margin-top: 66px;
}

.ml-68 {
  margin-left: 68px;
}

.mt-68 {
  margin-top: 68px;
}

.ml-70 {
  margin-left: 70px;
}

.mt-70 {
  margin-top: 70px;
}

.ml-72 {
  margin-left: 72px;
}

.mt-72 {
  margin-top: 72px;
}

.ml-74 {
  margin-left: 74px;
}

.mt-74 {
  margin-top: 74px;
}

.ml-76 {
  margin-left: 76px;
}

.mt-76 {
  margin-top: 76px;
}

.ml-78 {
  margin-left: 78px;
}

.mt-78 {
  margin-top: 78px;
}

.ml-80 {
  margin-left: 80px;
}

.mt-80 {
  margin-top: 80px;
}

.ml-82 {
  margin-left: 82px;
}

.mt-82 {
  margin-top: 82px;
}

.ml-84 {
  margin-left: 84px;
}

.mt-84 {
  margin-top: 84px;
}

.ml-86 {
  margin-left: 86px;
}

.mt-86 {
  margin-top: 86px;
}

.ml-88 {
  margin-left: 88px;
}

.mt-88 {
  margin-top: 88px;
}

.ml-90 {
  margin-left: 90px;
}

.mt-90 {
  margin-top: 90px;
}

.ml-92 {
  margin-left: 92px;
}

.mt-92 {
  margin-top: 92px;
}

.ml-94 {
  margin-left: 94px;
}

.mt-94 {
  margin-top: 94px;
}

.ml-96 {
  margin-left: 96px;
}

.mt-96 {
  margin-top: 96px;
}

.ml-98 {
  margin-left: 98px;
}

.mt-98 {
  margin-top: 98px;
}

.ml-100 {
  margin-left: 100px;
}

.mt-100 {
  margin-top: 100px;
}
</style>

<script>
export default {
  data() {
    return {
      menuData: [
        {
          path: "/",
          name: "home",
          label: "首页",
          icon: "s-home",
          url: "Home/Home",
        },

        {
          path: "/user",
          name: "user",
          label: "用户管理",
          icon: "user",
          url: "UserManage/UserManage",
        },
        {
          path: "/monitor",
          name: "monitor",
          label: "实时监测",
          icon: "location",
        },
        {
          label: "扶贫工作人员",
          icon: "location",
          children: [
            {
              path: "/FollowUpRequest",
              name: "FollowUpRequest",
              label: "回访请求",
              icon: "setting",
              url: "Other/FollowUpRequest",
            },
            {
              path: "/FollowUpPlan",
              name: "FollowUpPlan",
              label: "回访计划",
              icon: "setting",
              url: "Other/FollowUpPlan",
            },
            {
              path: "/register",
              name: "register",
              label: "进度登记",
              icon: "setting",
              url: "Other/register",
            },
            {
              path: "/Diary",
              name: "Diary",
              label: "回访日记",
              icon: "location",
              url: "Other/Diary",
            },

          ],
        },
        {
          label: "管理员",
          icon: "location",
          children: [
            // {
            //   path: "/review",
            //   name: "review",
            //   label: "政治面貌审核",
            //   icon: "setting",
            //   url: "Other/review",
            // },
            {
              path: "/application",
              name: "application",
              label: "回访申请",
              icon: "setting",
              url: "Other/application",
            },
            {
              path: "/Management",
              name: "Management",
              label: "申请管理",
              icon: "setting",
              url: "Other/Management",
            },
            {
              path: "/approval",
              name: "approval",
              label: "进度审批",
              icon: "setting",
              url: "Other/approval",
            },
            {
              path: "/Performance",
              name: "Performance",
              label: "成绩评估",
              icon: "setting",
              url: "Other/Performance",
            },
            {
              path: "/statistics",
              name: "statistics",
              label: "数据统计",
              icon: "setting",
              url: "Other/statistics",
            },
            {
              path: "/mall",
              name: "mall",
              label: "政策发布",
              icon: "setting",
              url: "MallManage/MallManage",
            },
          ],
        },
      ],
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    // 点击菜单
    clickMenu(item) {
      console.log(item);
      // 当页面的路由与跳转的路由不一致才允许跳转
      if (
        this.$route.path !== item.path &&
        !(this.$route.path === "/home" && item.path === "/")
      ) {
        this.$router.push(item.path);
      }
      this.$store.commit("selectMenu", item);
    },
  },
  computed: {
    // 没有子菜单
    noChildren() {
      return this.menuData.filter((item) => !item.children);
    },
    // 有子菜单
    hasChildren() {
      return this.menuData.filter((item) => item.children);
    },

    isCollapse() {
      return this.$store.state.tab.isCollapse;
    },
  },
};
</script>
